var editType = null;

$(function() {
	frame.secSelect($('#search_secId'));
});

function click_search() {
	var param = $("#search_param").form("getData");
	$('#dg').datagrid('load', param);
}

function click_add() {
	var ticker = $("#ticker").textbox("getValue");
	if (ticker == null || ticker == "") {
		$.messager.alert('错误', '请输入编码!', 'error');
	} else {
		$.post("./update.json",
			{
				ticker : ticker
			},
			function(data) {
				$('#dg').datagrid("loadData", data);
			}
		);
	}
}

function click_new(){
	editType = "new";
	frame.window.openWindow("/smdc/security/secdetail.jsp");
}

function click_row_delete() {
	$.messager.confirm('确认', '您确认想要删除吗？',
		function(r) {
			if (r) {
				deleteSecurity();
			}
		}
	);
}

function deleteSecurity() {
	var row = $('#dg').datagrid("getSelected");
	var index = $('#dg').datagrid("getRowIndex", row);
	$.post("./delete.json",
		row,
		function(data) {
			if (data.sucesse == true) {
				$('#dg').datagrid("deleteRow", index);
			}
		}
	);
}

function click_row_edit() {
	editType = "edit";
	frame.window.openWindow("/smdc/security/secdetail.jsp");
}